export default {
  functional: true,
  props: ['model', 'start', 'end'],
  render(h, { data, props, parent, listeners: on }) {
    const { model, start, end } = props
    const {
      attrs: { type },
      attrs
    } = data
    const onInput = value => {
      const [startValue, endValue] = value || []
      parent.$set(model, start, startValue)
      parent.$set(model, end, endValue)
    }
    on.input = /range$/.test(type) ? onInput : on.input
    attrs.value = /range$/.test(type) ? [model[start], model[end]] : attrs.value

    return <el-date-picker {...{ attrs, on }}></el-date-picker>
  }
}
